<#assign base=request.getContextPath()/>

<link data-name="vs/editor/editor.main" href="${base}/lib/monaco-editor/vs/editor/editor.main.css" rel="stylesheet"
      type="text/css">
<link href="${base}/lib/toastr/css/toastr.min.css" rel="stylesheet"/>
<header>
    <title>脚本编辑页面</title>
</header>

<body>
<div id="scriptContainer" style="min-width:70%;width:100%;height:95%;border:1px solid grey"></div>
<div id="debug">
    <h4 class="line-header" style="font-size:14px;font-weight:bold;;line-height:31px">调试日志</h4>
    <div class="line-info" id="logDiv">

    </div>
</div>

<div style="float: right">
    <input type="hidden" value="${interfaceScript.interfaceMockId!}" id="interfaceMockId">
    <input type="hidden" value="${interfaceScript.id!}" id="scriptId">
    <input type="hidden" value="${interfaceScript.script!}" id="script">
    <input type="hidden" value="${interfaceAliasName!}" id="interfaceAliasName">
    <input type="hidden" id="lastTimeFileSize" value="0"> <!--记录日志长度 -->
    <#if interfaceScript.id??>
        <button id="debugButton" value="on" style=".btn-success" onClick="scriptObj.debug(this.value)">开启调试</button>
    <#else >
        <button id="debugButton"  value="on" style=".btn-success;display: none" onClick="scriptObj.debug(this.value)">开启调试</button>
    </#if>
    <input id="btnClose" type="button" style=".btn-success" value="关闭本页" onClick="scriptObj.custom_close()"/>
    <input id="btnClose" type="button" style=".btn-success" value="保存" onClick="scriptObj.save()"/>

</div>
</body>

<script type="text/javascript" src="${base}/lib/jquery/jquery-3.1.1.min.js" charset="UTF-8"></script>
<script>var require = {paths: {'vs': '../lib/monaco-editor/vs'}};</script>
<script src="${base}/lib/monaco-editor/vs/loader.js"></script>
<script src="${base}/lib/monaco-editor/vs/editor/editor.main.nls.js"></script>
<script src="${base}/lib/monaco-editor/vs/editor/editor.main.js"></script>
<script src="${base}/lib/toastr/js/toastr.js"></script>
<script src="${base}/scripts/scriptPage.js"></script>
<script>
    var editor;
    $(document).ready(function () {
        $("#debug").hide();
        var scriptValue = $("#script").val();
        /** g修饰符用于执行全局匹配**/
        var reg = new RegExp('@@', "g")
        var scriptValue = scriptValue.replace(reg, '"');
        editor = monaco.editor.create(document.getElementById('scriptContainer'), {
            value: scriptValue,
            language: 'java'
             // theme:'vs-dark'
        });
        /**监听div的变化**/
        window.onresize = function () {
            if (editor) {
                editor.layout();
            }
        };
    });

</script>
<style>
    .line-info {
        width: 100%;
        display: table;
        box-sizing: border-box;
    }

    .line-header {
        font-size: 14px;
        background: #d6e2f7;
        line-height: 31px;
        text-indent: 10px;
        margin-top: 20px;
    }
</style>
